import java.util.*;
public class Demo16{
    static int N = 20;
    static boolean[] col= new boolean[N],row = new boolean[N],dg = new boolean[N],
            udg = new boolean[N];
    static int n;
    static char[][] g = new char[N][N];
    public static void dfs(int x,int y, int s){
        if(y == n){
            x++; y = 0;
        }
        if(x == n){
            if(s == n){
                for(int i = 0;i < n;i ++ ){
                    for(int j = 0;j < n ;j ++){
                        System.out.print(g[i][j]);
                    }
                    System.out.println();
                }
                System.out.println();
            }
            return;
        }


        dfs(x,y + 1,s);
        if(!row[x] && !col[y] && !dg[x + y] && !udg[x - y + n]){
            g[x][y] = 'Q';
            row[x] = col[y] = dg[x + y] = udg[x - y + n] = true;
            dfs(x,y + 1,s + 1);
            row[x] = col[y] = dg[x + y] = udg[x - y + n] = false;
            g[x][y] = '.';
        }
    }
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        n = scan.nextInt();
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                g[i][j] = '.';

            }
        }
        dfs(0,0,0);
    }
}